Update the Progress of an Outcome
Learning Path Outcomes have progress
associated with them. When a Learner accesses a Resource their progress can be updated as below.
This is an example of updating the progress of consuming a Video in an LMS.
Note that the data.compressed_seconds_watched
below uses string compression to generate the value, the implementation being as follows:
// Compresses `looooongggggggg` to `USC/l1,o5,n1,g8`
function compress(rawString) {
// This _must_ be "USC/"
var compressedString = "USC/";
var savedCharacter = rawString[0];
var savedCharacterCount = 0;
for (var i = 0; i < rawString.length; i += 1) {
var currentCharacter = rawString[i];
if (currentCharacter === savedCharacter) {
savedCharacterCount += 1;
} else {
compressedString += savedCharacter + savedCharacterCount.toString() + separator;
savedCharacter = currentCharacter;
savedCharacterCount = 1;
}
}
compressedString += savedCharacter + savedCharacterCount.toString();
return compressedString;
}
The other progress recording mechanisms can be found on the Registration Mutation List.
mutation setProgress {
registration {
recordVideoProgress(input: { registrationId: "bGVhcm5lcjo2NDM4", contentId: "Q29udGVudDoyMTI=", data: "{\"compressed_seconds_watched\":\"USC/011\"}" }) {
errors {
...Error
}
registration {
id
contentResults(filters: [{ field: contentId, operation: eq, value: "Q29udGVudDoyMTI=" }]) {
edges {
node {
...ContentFragment
}
}
}
}
}
}
}
fragment Error on FieldError {
label
value
message
}
fragment ContentFragment on ContentResult {
id
contentId
progress
score
scorePercent
attempts
completedAttempts
lastAccessed
status
... on VideoContentResult {
startAt
lastAccessed
progress
}
... on ExternalContentResult {
latestAttempt {
id
}
}
}